﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using IronPython.Hosting;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Scripting.Hosting;
using Xierun.WebApp.Models;

namespace Xierun.WebApp.Controllers
{
    public class AjaxPartController : Controller
    {
        public IActionResult Chat(string msg)
        {
            if (msg == "记录命令")
            {
                return Ok("请输入命令名称");
            }
            ScriptEngine pyEngine = Python.CreateEngine();//创建Python解释器对象            
            dynamic py = pyEngine.ExecuteFile(@"PythonLib\test1.py");//读取脚本文件
            int[] array = new int[9] { 9, 3, 5, 7, 2, 1, 3, 6, 8 };
            string reStr = py.main(array);//调用脚本文件中对应的函数

            return PartialView("Chat", reStr);
        }

        private void RecordCommand()
        {

        }

    }
}
